Skip to content

test(datetime): cover invalid timestamp errors in nanos conversions#3651

Open
vishnuprakaz wants to merge 1 commit into
apache:mainfrom
vishnuprakaz:test/timestamp-nanos-invalid-coverage
Open

test(datetime): cover invalid timestamp errors in nanos conversions#3651
vishnuprakaz wants to merge 1 commit into
apache:mainfrom
vishnuprakaz:test/timestamp-nanos-invalid-coverage

Conversation

@vishnuprakaz

Copy link
Copy Markdown
Contributor

Rationale for this change

Follow-up to #3505, addressing @ebyhr's suggestion to cover the untested error branches:
Invalid timestamp without zone in timestamp_to_nanos
Invalid timestamp with zone in timestamptz_to_nanos.

Are these changes tested?

Yes this PR is tests only.

Are there any user-facing changes?

No.



def test_timestamp_to_nanos_invalid_timestamp() -> None:
with pytest.raises(ValueError, match="Invalid timestamp without zone: invalid"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could verify the entire message:

re.escape("Invalid timestamp without zone: invalid (must be ISO-8601)")



def test_timestamp_to_nanos_invalid_timestamp() -> None:
with pytest.raises(ValueError, match="Invalid timestamp without zone: invalid"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could verify the entire message:

re.escape("Invalid timestamp without zone: invalid (must be ISO-8601)")

Same for test_timestamptz_to_nanos_invalid_timestamp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants